<?php
if (!defined('CURRENT_PATH')){
	die('Hacking attempt');
	}	
if($this->spArgs('step')){
	$step=$this->spArgs('step');
	//spClass("spHtml")->clearAll(TRUE); 
	$urls = array();
if($step==1){//第一步生产文章页。文章列表页的静态html（包含分页）
	$tempArr=array();
	$tempArrEle2=$tempArrEle3=0;
	$post=spClass('posts');
	$temp1=$post->findAll($conditions='fid!=0',$sort=null,$fields='id,fid');
	foreach($temp1 as $id=>$v){
		$id=$v['id'];
		if($v['fid']==1){
			$urls[]= array(array("main", "cases", array('id'=>$id)));
		}else if($v['fid']==2||$v['fid']==3){
			$urls[]= array(array("main", "datil", array('id'=>$id)));
			if($v['fid']==2){
				$tempArrEle2++;
			}else{
				$tempArrEle3++;
			}
		}
	}
	$tempArr=array(2=>$tempArrEle2,3=>$tempArrEle3);
	$fid2Page=ceil($tempArr[2]/16);
	$fid3Page=ceil($tempArr[3]/16);
	$urls[]= array(array("main", "articlelist", array('fid'=>2)),array("main", "articlelist", array('fid'=>3)));
	for($i=2;$i<=$fid2Page;$i++){
		$urls[]= array(array("main", "articlelist", array('fid'=>2,'page'=>$i)));
	}
	for($i=2;$i<=$fid3Page;$i++){
		$urls[]= array(array("main", "articlelist", array('fid'=>3,'page'=>$i)));
	}
	spClass('spHtml')->clear("main", "cases",null,null,true);
	spClass('spHtml')->clear("main", "datil",null,null,true);
	spClass('spHtml')->clear("main", "articlelist",null,null,true);
}else if($step==2){//第二步生成所有办公家具的HTML
	$ct=spClass('category');
	$temp1=$ct->findAll($conditions=null,$sort=null,$fields='id');
	foreach($temp1 as $id=>$v){
		$id=$v['id'];
		$urls[]= array(array("main", "furniture", array('id'=>$id)));
		}
	$urls[]= array(array("main", "furniture"));	
spClass('spHtml')->clear("main", "furniture",null,null,true);
}else if($step==3){//第三部内页
	for($i=1;$i<=5;$i++){
		$urls[]= array(array("main", "supporting", array('id'=>$i)));	
	}
	$urls[]= array(array("main", "supporting"));
	spClass('spHtml')->clear("main", "supporting",null,null,true);		
}else{//最后一步
	for($i=1;$i<=12;$i++){
			$urls[] = array(array("main", "article", array('id'=>$i)));
	}	
	$urls[]= array(array("main","index"));
	spClass('spHtml')->clear("main", "article",null,null,true);
	spClass('spHtml')->clear("main", "index",null,null,true);
}
//spClass('spHtml')->makeAll($urls);
sleep(5);
	echo '{"status":"1"}';	
	
}else{
$this->display('management/htmlgenprogress.html');
}